feat(image): honor alignment + surface display size for migrated images (#1404)#1406
feat(image): honor alignment + surface display size for migrated images (#1404)#1406SailingGreg wants to merge 8 commits into
Conversation
…-cms#1404 render follow-up) Renders the real RAFYC image node through astro-portabletext via the production dispatch (type.image -> Image.astro), default vs delegating override vs no-locals. All three emit a valid src: the override receives the full node intact and delegation to <Image> does NOT render empty. Confirms alignment is dropped.
…d images (emdash-cms#1404) Renderer (core/Image.astro): add alignment to the PT image node props and emit an emdash-image--align-{left,right,center,wide,full} figure class with default CSS (floats wrap text; wide/full span the column). Editor (admin): thread alignment through the PortableText<->TipTap serializer (both directions), the TipTap image node attribute/commands, and add an alignment selector to ImageDetailPanel. Also relax the Display Size gate from (width && height) to (src) so migrated WordPress images, which carry only displayWidth/displayHeight and no original dims, can still be resized; the aspect-ratio lock and reset-to-original now degrade gracefully when originals are unknown. Repro test asserts the renderer now emits the alignment class.
Float left/right (text wraps) and size center/wide/full in the TipTap image NodeView so the editor preview matches the published <Image> output.
🦋 Changeset detectedLatest commit: a260b73 The changes in this PR will be included in the next version bump. This PR includes changesets to release 14 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
All contributors have signed the CLA ✍️ ✅ |
|
I have read the CLA Document and I hereby sign the CLA |
Add a max-width:640px media query so left/right-aligned images drop to full-width blocks on phones instead of staying floated and cramped.
Overlapping PRsThis PR modifies files that are also changed by other open PRs:
This may cause merge conflicts or duplicated work. A maintainer will coordinate. |
Heads-up on the overlap noticeI checked the files this PR shares with the other open image PRs flagged by the overlap bot:
The three PRs are additive and orthogonal — each threads a different image attribute ( The one spot needing a deliberate (but compatible) resolution is the Merge-order preference: happy to go in whatever order suits maintainers, but this one is the smallest and is green/review-ready, so merging it first would let #704/#143 rebase trivially. If #143 lands first instead, I'll fold |
@emdash-cms/admin
@emdash-cms/auth
@emdash-cms/auth-atproto
@emdash-cms/blocks
@emdash-cms/cloudflare
@emdash-cms/contentful-to-portable-text
emdash
create-emdash
@emdash-cms/gutenberg-to-portable-text
@emdash-cms/plugin-cli
@emdash-cms/plugin-types
@emdash-cms/registry-client
@emdash-cms/registry-lexicons
@emdash-cms/sandbox-workerd
@emdash-cms/x402
@emdash-cms/plugin-ai-moderation
@emdash-cms/plugin-atproto
@emdash-cms/plugin-audit-log
@emdash-cms/plugin-color
@emdash-cms/plugin-embeds
@emdash-cms/plugin-field-kit
@emdash-cms/plugin-forms
@emdash-cms/plugin-webhook-notifier
commit: |
ascorbic
left a comment
There was a problem hiding this comment.
Overall good, but the tests need soem cleanup
| @@ -0,0 +1,61 @@ | |||
| /** | |||
There was a problem hiding this comment.
This file isn't testing anything real: it's just testing its own local implementations. Delete it: the other test file has the real tests.
| @@ -0,0 +1,70 @@ | |||
| import { PortableText } from "astro-portabletext"; | |||
| /** | |||
| * Faithful container render for the #1404 follow-up. | |||
There was a problem hiding this comment.
| * Faithful container render for the #1404 follow-up. |
| const imgSrc = (html: string) => html.match(/<img[^>]*\bsrc="([^"]*)"/)?.[1] ?? "(no <img>)"; | ||
|
|
||
| describe("faithful render of migrated image node", () => { | ||
| test("1. default type.image=Image.astro", async () => { |
| @@ -0,0 +1,24 @@ | |||
| import { getViteConfig } from "astro/config"; | |||
There was a problem hiding this comment.
Is this file used anywhere? It looks like nothing is running these tests
What does this PR do?
The Gutenberg to Portable Text importer captures WordPress image
alignmenton the image node, but it was dropped at render and not editable. This wires it through end to end and surfaces the existing display-size controls for migrated images.packages/core/src/components/Image.astro): emitemdash-image--align-{left,right,center,wide,full}from the nodesalignment`, with default CSS (left/right float and wrap text; center centers; wide/full span the column).packages/admin): threadalignmentthrough the PortableText/TipTap serializer (both directions) and the TipTap image node; add an Alignment selector toImageDetailPanel; reflect alignment in the image NodeView so the editor preview matches the published output.width && heighttosrcso WordPress-imported images (which carry onlydisplayWidth/displayHeight, no originals) are resizable; the aspect-ratio lock and reset-to-original degrade gracefully when originals are unknown.Validated end to end on a real WordPress-migrated site: editor -> save -> published page all agree on the canonical
alignmentfield.Closes #1404
Type of change
Checklist
pnpm typecheckpassespnpm lintpassespnpm testpasses (or targeted tests for my change)pnpm formathas been runAI-generated code disclosure
Screenshots / test output
Container-render repro asserts the alignment class is emitted (default render and via a delegating component override); validated end to end on a live WordPress-migrated site (editor -> save -> published render).